Ext.define('sheath.view.base.sheetGrid', {
    extend: 'Ext.grid.Panel',
    requires: [ 
        'Ext.grid.selection.SpreadsheetModel',
        'Ext.grid.plugin.Clipboard',
        'sheath.view.base.exGridFilters',
       'sheath.view.base.sheetGridController'
    ],

    /* xtype: 'finaVerfiyGrid', */
    /* controller: 'finaVerfiyGridController', */
    /* stateId: 'gridStateId',*/
    /* title: '',*/
    controller: 'sheetGridController',

    stateful: true, /* enable state manage */
    columnLines: false, /* if true adds column line styling */
    frame: true,/* show frame of grid */
    resizable: false,

    selModel: {
        type: 'checkboxmodel',
        checkboxSelect: true,
        pruneRemoved: true,
        cellSelect: false
    },

    /* plugins'clipboard' : Enable CTRL+C/X/V hot-keys to copy/cut/paste to the system clipboard.*/
  /*  plugins: ['clipboard', 'gridfilters'],*/
    plugins: ['clipboard', 'gfilters'],//自定义查询框
    listeners: {
        //selectionchange: 'onSelectionChange',
        itemcontextmenu: 'onItemcontextmenu'
    },
   
    

    //tbar: ['->', {
    //    xtype: 'component',
    //    reference: 'status'
    //},/*
    //    {
    //    text: 'Show Filters...',
    //    tooltip: 'Show filter data for the store',
    //    handler: 'onShowFilters'
    //    },*/
    //    {
    //    text: '清空过滤条件',
    //    tooltip: '清空所有过滤条件',
    //    handler: 'onClearFilters'
    //}],

    /*checkBox selected Index value*/
    getSelectedCount:function(){
        var rs = this.getSelectionModel().selected;
        if (rs == null || rs.selectedRecords.items.length == 0) {
            Ext.MessageBox.alert('Error', '没有选择');
        } else {

            Ext.each(rs.selectedRecords.items, function () {
                //console.log(this.data);
            });

            Ext.Msg.alert('Error', rs.selectedRecords.items.length);

        }
        //.selectedRecords.items;
        
        //Ext.each(rs,function(){
        //    console.log(this);
        //});
    },
    /*主键的列名 默认为IndexID, 如果不是覆盖即可*/
    indexIdColumnName: 'IndexID',
    defaultPagesize:40,

    initComponent: function () {
        var gridstore = this.store;     
        initPagesize = this.defaultPagesize;

        combo = Ext.create('Ext.form.ComboBox', {
            name: 'pagesize',
            hiddenName: 'pagesize',
            store: Ext.StoreMgr.get('gridPagesize'),
            valueField: 'value',
            displayField: 'text',
            emptyText: 40,
            width: 50,
            listeners: {
                select: 'changePage'
            }
        });
        Ext.apply(this, {
            bbar: Ext.create('Ext.PagingToolbar', {
                store: gridstore,
                displayInfo: true,
                dock: 'bottom',
                pageSize: initPagesize,
                displayMsg: ' 总 {2} 条记录 , 当前显示 {0} - {1} 条',
                emptyMsg: "没有数据",
                items: ['-', '每页显示', combo, '条']
            }),
        });

       
       gridstore.proxy.url = gridstore.url;
       gridstore.proxy.extraParams = gridstore.extraParams;
       gridstore.proxy.reader.idProperty = gridstore.idProperty;
      /*    gridstore.load({
            params: {
                start: 0,
                limit: initPagesize
            }
        });*/
        this.callParent();
    },
   
    init: function () {
        //console.log('init Ext.grid.Panel');
    }


    ,
    initViewModel: function () {
        //console.log('initViewModel Ext.grid.Panel');
    }
    ,
    destroy: function () {
        this.callParent();
        //console.log('destroy Ext.grid.Panel');
    }
});